package jaxb.metagrammar;

import java.util.UUID;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import metagrammar.Type;
import application.Application;

public class TypeToUUIDStringAdapter extends XmlAdapter<String, Type> {
    
    @Override
    public Type unmarshal(String v) throws Exception
    {
        TypeContext context = Application.injector.getInstance(TypeContext.class);
        return context.getType(UUID.fromString(v));
    }
    
    @Override
    public String marshal(Type v) throws Exception
    {
        return v.getId().toString();
    }
    
}
